<?php include_once './application/views/sys_admin/common/header.php';  ?>
<div class=" definewidth m20">
		<form action="/sys_admin/accountcash/zhs_accountcashlist/" method="get" id="cashForm" class="form-inline definewidth m20">
	  			用户名：<input type="text" id="username" name="username" style="width: 100px;" value="<?php echo $username;?>" />
	  			实名：<input type="text" id="realname" name="realname" style="width: 100px;" value="<?php echo $realname;?>" />
	  			类型：<select id="is_loan" name="is_loan">
	  				<option value="-1" <?php if($is_loan==-1){?>selected="selected"<?php }?>>所有</option>
	  				<?php foreach($user_loan as $key=>$value){?>
	  				<option value="<?php echo $key?>" <?php if($is_loan==$key){?>selected="selected"<?php }?>><?php echo $value;?></option>
	  				<?php }?>
	  			</select>
	  			状态：<select id="fstatus" name="fstatus">
	  				<option value="-1" <?php if($fstatus==-1){?>selected="selected"<?php }?>>所有</option>
	  				<?php foreach($account_cash_status as $key=>$value){?>
	  				<option value="<?php echo $key?>" <?php if($fstatus==$key){?>selected="selected"<?php }?>><?php echo $value;?></option>
	  				<?php }?>
	  			</select>
	  			开始时间：<input type="text" id="strtime" name="strtime" style="width: 100px;" value="<?php echo $strtime;?>"  onfocus="WdatePicker()" class="Wdate" />
	  			结束时间：<input type="text" id="endtime" name="endtime" style="width: 100px;" value="<?php echo $endtime;?>"  onfocus="WdatePicker()" class="Wdate" />
	  			<button type="button" class="btn btn-primary"  onclick="this.form.submit();" >查询</button>
	  			<button type="button" class="btn btn-success"  onclick="href('/sys_admin/accountcash/accountcashexcel/?username=<?php echo $username;?>&is_loan=<?php echo $is_loan;?>&fstatus=<?php echo $fstatus;?>&strtime=<?php echo $strtime;?>&endtime=<?php echo $endtime;?>');" >导出数据</button>
	  	</form>
		<table class="table table-bordered table-hover definewidth m10">
			 <thead>
			    <tr>
			        <th><strong>序号</strong></th>
					<th><strong>会员名</strong></th>
					<th><strong>类型</strong></th>
					<th><strong>帐号</strong></th>
					<th><strong>提现金额</strong></th>
					<th><strong>到账金额</strong></th>
					<th><strong>手续费</strong></th>
					<th><strong>申请时间</strong></th>
					<th><strong>审核时间</strong></th>
					<th><strong>状态</strong></th>
					<th><strong>明细</strong></th>
					<th><strong>操作</strong></th>
					<th>
				  	<input type="checkbox" name="alldaozhang" id="alldaozhang" />
				  	<input type="button" id="btn_batchdz" value="到账" onclick="batchdz()" />
				  	</th>
			    </tr>
			   </thead>
			  <?php foreach($accountcash_list as $key=>$accountcash){?>
			  <tr>
			  	<td><?php echo $accountcash['id'];?></td>
				<td><a href="javascript:search('<?php echo $accountcash['username'];?>');"><?php echo $accountcash['username'];?></a></td>
				<td><?php echo $user_loan[$accountcash['is_loan']];?></td>
				<td><?php echo $accountcash['account'];?></td>
				<td><?php echo number_format($accountcash['total'],2);?></td>
				<td><?php echo number_format($accountcash['credited'],2);?></td>
				<td><?php echo number_format($accountcash['fee'],2);?></td>
				<td><?php echo date('m-d H:i', $accountcash['add_time']);?></td>
				<td><?php echo date('m-d H:i', $accountcash['verify_time']);?></td>
				<td><?php echo $account_cash_status[$accountcash['fstatus']];?></td>
				<td><a  href="/sys_admin/accountlog/zhs_accountloglist/?username=<?php echo $accountcash['username'];?>">资金流水</a></td>
				<td>
				<?php if($accountcash['fstatus'] == 0){?>
					<a href="javascript:verify(<?php echo $accountcash['id'];?>);">审核</a>	
				<?php }elseif($accountcash['fstatus'] == 1){?>
					<a href="javascript:review(<?php echo $accountcash['id'];?>);">到账</a>
				<?php }?>
				</td>
				<td>
			  	<?php if($accountcash['fstatus'] == 1){?><input type="checkbox" name="daozhang" id="daozhang" value="<?php echo $accountcash['id'];?>"/><?php }?>
			  	</td>
			  </tr>
			  <?php }?>
			  	<tr>
			  	<td colspan="13"  class="invbd_page"><?php echo $this->pagination->create_links();?></td>
			  	</tr>
		</table>
</div>

<script type="text/javascript">
$("#alldaozhang").click(function(){
   $("input[name='daozhang']").prop("checked",$(this).prop("checked"));
});
function search(username){
	$("#username").val(username);
	$("#cashForm").submit();
}
function batchdz(){
	$("#btn_batchdz").attr('disabled',true);
	//alert($("input[name='daozhang'][checked]").val());
	var chk_value = [];    
    $('input[name="daozhang"]:checked').each(function(){    
     	chk_value.push($(this).val());    
    });
    $( "#dialog5" ).dialog({
		width:400,
		modal:true, //蒙层（弹出会影响页面大小）
		title:'提现到账审核', 
		buttons:{"确定":function(){$(this).dialog("close");}},
		close: function() {
			location.reload();
		}
	});
    $( "#msg5" ).html('批量审核中...');
    $.ajax({
		type: "POST",
		url: "/sys_admin/accountcash/batchreview",
		data: "ids="+chk_value,
		success: function(msg){
	        if(msg == 1){
	        	//alert("批量审核通过");
	        	$( "#msg5" ).html('批量审核通过');
	        }else{
	        	$( "#msg5" ).html('批量审核失败');
	        	//alert("批量审核失败");
		    }
		},
		dataType: "text"
	});
}
</script>
<div id="dialog" title="系统提示" style="display:none;">
<table class="table table-bordered table-hover m10">
	<input type="hidden" name="id" id="id" />
	<tr>
        <td class="tableleft">总金额</td>
        <td><span id="account_total"></span></td>
        <td class="tableleft">可用金额</td>
        <td><span id="account_use"></span></td>
   	</tr>
   	<tr>
        <td class="tableleft">投标冻结总金额</td>
        <td><span id="account_tender"></span></td>
        <td class="tableleft">待收总金额</td>
        <td><span id="account_coll"></span></td>
   	</tr>
   	<tr>
        <td class="tableleft">冻结总金额</td>
        <td><span id="account_nouse"></span></td>
        <td class="tableleft">本次提现冻结金额</td>
        <td><span id="account_cash_now"></span></td>
   	</tr>
   	<tr>
        <td class="tableleft">状态</td>
        <td>
        <input type="radio" name="fstatus" id="fstatus" checked="checked" value="1"/>审核通过，线下网银转账<br>
		 <input type="radio" name="fstatus" id="fstatus" value="2"/>审核不通过 ，备注中填写不通过原因
		</td>
        <td class="tableleft">交易结果</td>
        <td><div id="msg" style="text-align:center;color:red">&nbsp;</div></td>
   	</tr>
   	<tr>
        <td class="tableleft">备注</td>
        <td colspan="3"><textarea  id="verify_remark" name="verify_remark" style="width: 400px;height: 24px;">通过审核</textarea></td>
   	</tr>
</table> 	
</div>
<script>
function verify(id){
	if(id>0){
		$.ajax({
			type: "GET",
			url: "/sys_admin/account/jsinfo/"+id,
			data: "",
			success: function(data){
				$( "#dialog" ).dialog({
					width:600,
					modal:true, //蒙层（弹出会影响页面大小）
					title:'提现审核', 
					buttons:{"提交":function(){verifysub();},"关闭":function(){$(this).dialog("close");}}
				});
				$("#id").val(id);
				$("#account_total").html(data.total);
				$("#account_use").html(data.use_money);
				$("#account_nouse").html(data.no_use_money);
				$("#account_coll").html(data.collection);
				
				//alert(data.account_tender );
				//exit;
				if(data.account_tender == null || data.account_tender ==0){
					$("#account_tender").html(0.00);
				}else{
					$("#account_tender").html(data.account_tender);
				}
				$("#account_cash").html(data.account_cash);
				$("#account_cash_now").html(data.account_cash_now);
			},
			dataType: "json"
		});
	}
}

function verifysub(){
	$( "#dialog" ).dialog({
		width:400,
		modal:true, //蒙层（弹出会影响页面大小）
		title:'提现审核',
		buttons:{"提交":function(){},"关闭":function(){}}
	});
	if($('#verify_remark').val() == ''){
		$("#msg").html("请填写备注");
		return false;
	}
	$("#msg").html('提交中...');
	$.ajax({
			type: "POST",
			url: "/sys_admin/accountcash/verify",
			data: "id="+$('#id').val()+"&fstatus="+$('input:radio[name="fstatus"]:checked').val()+"&verify_remark="+$('#verify_remark').val(),
			success: function(msg){
		        $("#msg").html(msg);
				setTimeout(function(){
						location.reload();
				},3000);
			},
			dataType: "text"
		});
}


</script>

<div id="dialog1" title="系统提示" style="display:none;">
<div id="msg1" style="text-align:center;color:red">&nbsp;</div>
<input type="hidden" name="id" id="id" />
状态：<input type="radio" name="fstatus1" id="fstatus1" checked="checked" value="4"/>已到帐
	  <input type="radio" name="fstatus1" id="fstatus1" value="2"/>未到帐，提现失败<br /><br />
备注/结果：<textarea  id="review_remark" name="review_remark" style="width: 300px;height: 100px;">已到帐</textarea><br />
</div>
<script>
function review(id){
	if(id>0){
		$( "#dialog1" ).dialog({
			width:400,
			modal:true, //蒙层（弹出会影响页面大小）
			title:'到账审核', 
			buttons:{"提交":function(){reviewsub();},"关闭":function(){$(this).dialog("close");}},
		});
		$("#id").val(id);
	}
}

function reviewsub(){
	$( "#dialog1" ).dialog({
		width:400,
		modal:true, //蒙层（弹出会影响页面大小）
		title:'到帐审核',
		buttons:{"提交":function(){},"关闭":function(){}}
	});
	if($('#review_remark').val() == ''){
		$("#msg1").html("请填写备注");
		return false;
	}
	$("#msg1").html('提交中...');
	$.ajax({
			type: "POST",
			url: "/sys_admin/accountcash/review",
			data: "id="+$('#id').val()+"&fstatus="+$('input:radio[name="fstatus1"]:checked').val()+"&review_remark="+$('#review_remark').val(),
			success: function(msg){
		        $( "#dialog1" ).dialog();
		        $("#msg1").html('操作成功');
		        if(msg=='1'){
		        	$("#review_remark").val(msg);
		        }else{
		        	$("#review_remark").val(msg);
			    }
				setTimeout(function(){
						location.reload();
				},3000);
			},
			dataType: "text"
		});
}


</script>
<div id="dialog5" title="系统提示" style="display:none;">
<div id="msg5" style="text-align:center;color:red">&nbsp;</div>
</div>
